﻿using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using YFurion.Entities;

namespace UpperComputer.Core.Entities
{
    public class LoginInOrOutLog : YEntity, IEntityTypeBuilder<LoginInOrOutLog>
    {
        public string Account { get; set; }
        public string UserId { get; set; }
        public string UserName { get; set; }
        public bool LoginInOrOut { get; set; }
        public string Ip { get; set; }
        public DateTime OperationTime { get; set; }
        public bool IsExpired { get; set; }

        public void Configure(EntityTypeBuilder<LoginInOrOutLog> entity, DbContext dbContext, Type dbContextLocator)
        {
            entity.Property(e => e.Id)
                .ValueGeneratedNever();

            entity.Property(e => e.Account)
                .IsRequired()
                .HasMaxLength(50)
                .IsUnicode(false);

            entity.Property(e => e.Ip)
                .IsRequired()
                .HasMaxLength(50)
                .IsUnicode(false);

            entity.Property(e => e.UserId)
                .IsRequired()
                .HasMaxLength(50)
                .IsUnicode(false);

            entity.Property(e => e.UserName)
                .IsRequired()
                .HasMaxLength(50);
        }
    }
}
